package com.geen.tuoke.ui.dialog

import android.annotation.SuppressLint
import android.content.Context
import androidx.databinding.DataBindingUtil
import com.geen.tuoke.BuildConfig
import com.geen.tuoke.R
import com.geen.tuoke.databinding.DialogUpdateBinding
import com.geen.tuoke.utils.ext.dp2px
import com.geen.tuoke.utils.ext.toastShort
import com.geen.tuoke.widget.dialog.DialogViewHolder
import com.geen.tuoke.widget.dialog.XXDialog
import com.tencent.bugly.Bugly
import com.tencent.bugly.beta.Beta

/**
 * @Author LuoJi
 * @Date 2021/12/30-16:28
 * @Desc
 */
@SuppressLint("SetTextI18n")
class DialogUpdate(context: Context):XXDialog(context, R.layout.dialog_update) {

    private var mBinding : DialogUpdateBinding? = null

    init {
        setWidthAndHeight(dp2px(288f), dp2px(214f))
        setCanceledOnTouchOutside(false)
        mBinding?.tvVersion?.text = "当前版本："+BuildConfig.VERSION_NAME
    }


    override fun convert(holder: DialogViewHolder) {
        mBinding = DataBindingUtil.bind(holder.convertView)
        mBinding?.apply {
            ivClose.setOnClickListener {
                dismiss()
            }
            btnSure.setOnClickListener {
                toastShort("检查更新")
                Beta.checkUpgrade(true,true)
            }
        }
    }
}